package com.sangu.dianxiu.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.ArrayList;

/**
 * 首页广告adapter
 * Created by sg2 on 2015/12/29.
 */
public class AdvPagerAdapter extends PagerAdapter{
    private ArrayList<ImageView> advs=null; //广告图片

    public AdvPagerAdapter(ArrayList<ImageView> advs) {
        this.advs = advs;
    }

    @Override
    public int getCount() {
        return advs==null?0:advs.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object o) {
        return view==o;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(advs.get(position));
        return advs.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
       container.removeView(advs.get(position));
    }
}
